﻿namespace LeetCodeProject._0001_1000._001_100._51_60._055;

public class Solution
{
    public bool CanJump(int[] nums)
    {
        if (nums == null || nums.Length == 0)
            return false;
        var nextPos = 0 + nums[0];
        var i = 0;
        while (i <= nextPos)
        {
            nextPos = Math.Max(nextPos, i + nums[i]);
            if (nextPos >= nums.Length - 1)
                return true;
            i++;
        }

        return false;
    }
}